## 项目启动
import time

from crawler.connection import filter_push_redis, redis_conn, redis_shedana

url_list = [
    {
        'sex': 'men',
        'category': 'Clothing>>blazers',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/blazers'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>cashmere',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/cashmere'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>casual-shirts',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/casual-shirts'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>coats-and-jackets',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/coats-and-jackets'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>corduroy',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/corduroy'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>denim',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/denim'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>formal-shirts',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/formal-shirts'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>jeans',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/jeans'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>knitwear',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/knitwear'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>linen',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/linen'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>polo-shirts',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/polo-shirts'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>pyjamas',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/pyjamas'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>shorts',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/shorts'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>suits',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/suits'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>sweats',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/sweats'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>swimwear',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/swimwear'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>t-shirts',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/t-shirts'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>trousers',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/trousers'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>tuxedos',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/tuxedos'
    },
    {
        'sex': 'men',
        'category': 'Clothing>>underwear',
        'href': 'https://www.mrporter.com/en-us/mens/clothing/underwear'
    },
    {
        'sex': 'men',
        'category': 'Shoes>>boat-shoes',
        'href': 'https://www.mrporter.com/en-us/mens/shoes/boat-shoes'
    },
    {
        'sex': 'men',
        'category': 'Shoes>>boots',
        'href': 'https://www.mrporter.com/en-us/mens/shoes/boots'
    },
    {
        'sex': 'men',
        'category': 'Shoes>>brogues',
        'href': 'https://www.mrporter.com/en-us/mens/shoes/brogues'
    },
    {
        'sex': 'men',
        'category': 'Shoes>>derby-shoes',
        'href': 'https://www.mrporter.com/en-us/mens/shoes/derby-shoes'
    },
    {
        'sex': 'men',
        'category': 'Shoes>>driving-shoes',
        'href': 'https://www.mrporter.com/en-us/mens/shoes/driving-shoes'
    },
    {
        'sex': 'men',
        'category': 'Shoes>>espadrilles',
        'href': 'https://www.mrporter.com/en-us/mens/shoes/espadrilles'
    },
    {
        'sex': 'men',
        'category': 'Shoes>>formal-shoes',
        'href': 'https://www.mrporter.com/en-us/mens/shoes/formal-shoes'
    },
    {
        'sex': 'men',
        'category': 'Shoes>>loafers',
        'href': 'https://www.mrporter.com/en-us/mens/shoes/loafers'
    },
    {
        'sex': 'men',
        'category': 'Shoes>>monk-strap-shoes',
        'href': 'https://www.mrporter.com/en-us/mens/shoes/monk-strap-shoes'
    },
    {
        'sex': 'men',
        'category': 'Shoes>>oxford-shoes',
        'href': 'https://www.mrporter.com/en-us/mens/shoes/oxford-shoes'
    },
    {
        'sex': 'men',
        'category': 'Shoes>>sandals',
        'href': 'https://www.mrporter.com/en-us/mens/shoes/sandals'
    },
    {
        'sex': 'men',
        'category': 'Shoes>>shoe-accessories',
        'href': 'https://www.mrporter.com/en-us/mens/shoes/shoe-accessories'
    },
    {
        'sex': 'men',
        'category': 'Shoes>>slides',
        'href': 'https://www.mrporter.com/en-us/mens/shoes/slides'
    },
    {
        'sex': 'men',
        'category': 'Shoes>>slippers',
        'href': 'https://www.mrporter.com/en-us/mens/shoes/slippers'
    },
    {
        'sex': 'men',
        'category': 'Shoes>>sneakers',
        'href': 'https://www.mrporter.com/en-us/mens/shoes/sneakers'
    },
    {
        'sex': 'men',
        'category': 'Shoes>>sport-shoes',
        'href': 'https://www.mrporter.com/en-us/mens/shoes/sport-shoes'
    },
    {
        'sex': 'men',
        'category': 'Shoes>>suede-shoes',
        'href': 'https://www.mrporter.com/en-us/mens/shoes/suede-shoes'
    },
    {
        'sex': 'men',
        'category': 'Shoes>>winter-shoes',
        'href': 'https://www.mrporter.com/en-us/mens/shoes/winter-shoes'
    },
    {
        'sex': 'men',
        'category': 'Accessories>>bags',
        'href': 'https://www.mrporter.com/en-us/mens/accessories/bags'
    },
    {
        'sex': 'men',
        'category': 'Accessories>>belts',
        'href': 'https://www.mrporter.com/en-us/mens/accessories/belts'
    },
    {
        'sex': 'men',
        'category': 'Accessories>>cufflinks-and-tie-clips',
        'href': 'https://www.mrporter.com/en-us/mens/accessories/cufflinks-and-tie-clips'
    },
    {
        'sex': 'men',
        'category': 'Accessories>>fine-jewellery',
        'href': 'https://www.mrporter.com/en-us/mens/accessories/fine-jewellery'
    },
    {
        'sex': 'men',
        'category': 'Accessories>>glasses',
        'href': 'https://www.mrporter.com/en-us/mens/accessories/glasses'
    },
    {
        'sex': 'men',
        'category': 'Accessories>>gloves',
        'href': 'https://www.mrporter.com/en-us/mens/accessories/gloves'
    },
    {
        'sex': 'men',
        'category': 'Accessories>>hats',
        'href': 'https://www.mrporter.com/en-us/mens/accessories/hats'
    },
    {
        'sex': 'men',
        'category': 'Accessories>>jewellery',
        'href': 'https://www.mrporter.com/en-us/mens/accessories/jewellery'
    },
    {
        'sex': 'men',
        'category': 'Accessories>>keyrings',
        'href': 'https://www.mrporter.com/en-us/mens/accessories/keyrings'
    },
    {
        'sex': 'men',
        'category': 'Accessories>>pocket-squares',
        'href': 'https://www.mrporter.com/en-us/mens/accessories/pocket-squares'
    },
    {
        'sex': 'men',
        'category': 'Accessories>>scarves',
        'href': 'https://www.mrporter.com/en-us/mens/accessories/scarves'
    },
    {
        'sex': 'men',
        'category': 'Accessories>>socks',
        'href': 'https://www.mrporter.com/en-us/mens/accessories/socks'
    },
    {
        'sex': 'men',
        'category': 'Accessories>>sunglasses',
        'href': 'https://www.mrporter.com/en-us/mens/accessories/sunglasses'
    },
    {
        'sex': 'men',
        'category': 'Accessories>>tech-accessories',
        'href': 'https://www.mrporter.com/en-us/mens/accessories/tech-accessories'
    },
    {
        'sex': 'men',
        'category': 'Accessories>>ties',
        'href': 'https://www.mrporter.com/en-us/mens/accessories/ties'
    },
    {
        'sex': 'men',
        'category': 'Accessories>>umbrellas',
        'href': 'https://www.mrporter.com/en-us/mens/accessories/umbrellas'
    },
    {
        'sex': 'men',
        'category': 'Accessories>>wallets',
        'href': 'https://www.mrporter.com/en-us/mens/accessories/wallets'
    },
    {
        'sex': 'men',
        'category': 'Accessories>>watches',
        'href': 'https://www.mrporter.com/en-us/mens/accessories/watches'
    },
    {
        'sex': 'kid',
        'category': 'Clothing>>coats-and-jackets',
        'href': 'https://www.mrporter.com/en-hk/mens/kidswear/clothing/coats-and-jackets'
    },
    {
        'sex': 'kid',
        'category': 'Clothing>>knitwear',
        'href': 'https://www.mrporter.com/en-hk/mens/kidswear/clothing/knitwear'
    },
    {
        'sex': 'kid',
        'category': 'Clothing>>shirts',
        'href': 'https://www.mrporter.com/en-hk/mens/kidswear/clothing/shirts'
    },
    {
        'sex': 'kid',
        'category': 'Clothing>>shorts',
        'href': 'https://www.mrporter.com/en-hk/mens/kidswear/clothing/shorts'
    },
    {
        'sex': 'kid',
        'category': 'Clothing>>sweats',
        'href': 'https://www.mrporter.com/en-hk/mens/kidswear/clothing/sweats'
    },
    {
        'sex': 'kid',
        'category': 'Clothing>>swimwear',
        'href': 'https://www.mrporter.com/en-hk/mens/kidswear/clothing/swimwear'
    },
    {
        'sex': 'kid',
        'category': 'Clothing>>t-shirts-and-polo-shirts',
        'href': 'https://www.mrporter.com/en-hk/mens/kidswear/clothing/t-shirts-and-polo-shirts'
    },
    {
        'sex': 'kid',
        'category': 'Clothing>>trousers-and-jeans',
        'href': 'https://www.mrporter.com/en-hk/mens/kidswear/clothing/trousers-and-jeans'
    }
]

for index, url in enumerate(url_list):
    task = {
        "jobId": index,
        'url': url,
        # 'code': url,
        'domain': 'mrporter'.upper(),
        'filename': 'main',
        'types': 'electronic_business',
        "scheduleTime": int(time.time() * 1000),
        "triggerChannel": 'SONIC_SPIDER',
    }
    result = filter_push_redis(redis_conn, f'{task["types"]}_{task["filename"]}_{task["domain"]}', task)
    # result = filter_push_redis(redis_shedana, f'{task["types"]}_{task["filename"]}_{task["domain"]}', task)
    print(result)

# https://restnewdev.innodealing.com/redis-spider-service/victor_spider?kernelCode=['region_nanchong_day','region_suzhou_tjj_day', 'region_ningbo_tjj_day']&originName=['区域经济-南充','区域经济-苏州', '区域经济-宁波']&create_table_rule=custom&mail_switch=true&mail_receiver=&table_name=region_link_type
